package com.caption.support;

import com.alibaba.ttl.TransmittableThreadLocal;

/**
 * 父子线程存放变量
 */
public class TxContextHolder {
    private static final TransmittableThreadLocal<TxContext> contextHolder = new TransmittableThreadLocal<TxContext>() {
        @Override
        protected TxContext initialValue() {
            return new DefaultTxContext();
        }
    };

    public static TxContext getCurrentContext() {
        return contextHolder.get();
    }

    public static void clearCurrentContext() {
        contextHolder.remove();
    }
}
